<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <script>
      let arr = [1, 2, 3];
      // ...arr; 1 2 3
      console.log(...arr); //，会被log解析自动去掉

      let arr1 = [4, 5, 6];
      //合并数组1.
      let arr2 = [...arr, ...arr1];
      console.log(arr2);

      console.log('-----------------');
      //合并数组2.
      arr.push(...arr1);
      console.log(arr);

      /*利用dom 获得是伪数组 可以用 扩展方法转为真正的数组 调用数组的方法*/
      var div1 = document.querySelectorAll('div');
      console.log(div1);
      var div2 = [...div1];
      div2.push('a');
      console.log(div2,'合并伪数组');

      //2.
      let arr4 = {
              "0": 'zks',
              "1": 'ls',
              "2": 'zs',
              "length": 3
          }
          /*伪数组变成数组*/

      var ary = Array.from(arr4,(ele,index)=>{
          console.log(ele,index,'from');
          return ele
      }); //拷贝
      console.log(ary,'52');

      //find方法 查找数组中第一个符合条件的值
      let arr5 = [{
          id: 1,
          name: 'zks'
      }, {
          id: 2,
          name: 'lisi'
      }];
      let target = arr5.find((item) => item.id == 2)
      console.log(target);

      //findindex  返回第一个满足条件的索引
      let arr6 = [1, 5, 6, 10];
      let index = arr6.findIndex(item => item >= 9);
      console.log(index);

      //include 表示数组是否包含给定的值
      var arr7 = [1, 2, 3];
      console.log(arr7.includes(2));


    </script>
  </body>
</html>
